//
//  PBSearchOneCell.m
//  PBHomeDemo
//
//  Created by Playboy on 2018/1/10.
//  Copyright © 2018年 tmkj. All rights reserved.
//

#import "PBSearchOneCell.h"

@interface PBSearchOneCell ()
@property (strong, nonatomic) IBOutlet UILabel *nameLabel;
@property (strong, nonatomic) IBOutlet UILabel *desLabel;
@property (strong, nonatomic) IBOutlet UIButton *firstButton;
@property (strong, nonatomic) IBOutlet UIButton *secButton;
@property (strong, nonatomic) IBOutlet UIButton *threeButton;
@property (strong, nonatomic) IBOutlet UIButton *fourButton;
@property (nonatomic, strong) NSIndexPath *indexPath;
@end

@implementation PBSearchOneCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.firstButton.layer.borderWidth = 1.0f;
    self.firstButton.layer.borderColor = [UIColor tm_searchBackgroundColor].CGColor;
    self.firstButton.layer.cornerRadius = 3;
    self.secButton.layer.borderWidth = 1.0f;
    self.secButton.layer.borderColor = [UIColor tm_searchBackgroundColor].CGColor;
    self.secButton.layer.cornerRadius = 3;
    self.threeButton.layer.borderWidth = 1.0f;
    self.threeButton.layer.borderColor = [UIColor tm_searchBackgroundColor].CGColor;
    self.threeButton.layer.cornerRadius = 3;
    self.fourButton.layer.borderWidth = 1.0f;
    self.fourButton.layer.borderColor = [UIColor tm_searchBackgroundColor].CGColor;
    self.fourButton.layer.cornerRadius = 3;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)buttonClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected) {
        [sender setBackgroundColor:UIColorWithRGB(243,159,13)];
        if (self.delegate && [self.delegate respondsToSelector:@selector(chooseTheType:row:)]) {
            [self.delegate chooseTheType:sender.titleLabel.text row:self.indexPath.row];
        }
    }else {
        [sender setBackgroundColor:[UIColor whiteColor]];
        if (self.delegate && [self.delegate respondsToSelector:@selector(cancleTheType:row:)]) {
            [self.delegate cancleTheType:sender.titleLabel.text row:self.indexPath.row];
        }
    }
}

-  (void)refreshWithIndexPath:(NSIndexPath *)indexPath reset:(BOOL)reset{
    self.indexPath = indexPath;
    if (reset) {
        self.firstButton.selected = NO;
        self.secButton.selected = NO;
        self.threeButton.selected = NO;
        self.fourButton.selected = NO;
        [self.firstButton setBackgroundColor:[UIColor whiteColor]];
        [self.secButton setBackgroundColor:[UIColor whiteColor]];
        [self.threeButton setBackgroundColor:[UIColor whiteColor]];
        [self.fourButton setBackgroundColor:[UIColor whiteColor]];
    }
    if (indexPath.row == 0) {
        self.nameLabel.text = @"荣者友家";
        self.desLabel.text = @"【合租】百万荣者客的品质合租公寓";
    }else if (indexPath.row == 1) {
        self.nameLabel.text = @"荣者整租";
        self.desLabel.text = @"【整租】成套出租的风格设计公寓";
    }
}

@end
